using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;
namespace SubSonic.Generated
{
	/// <summary>
	/// Strongly-typed collection for the Listdetail class.
	/// </summary>
    [Serializable]
	public partial class ListdetailCollection : ActiveList<Listdetail, ListdetailCollection>
	{	   
		public ListdetailCollection() {}
        
        /// <summary>
		/// Filters an existing collection based on the set criteria. This is an in-memory filter
		/// Thanks to developingchris for this!
        /// </summary>
        /// <returns>ListdetailCollection</returns>
		public ListdetailCollection Filter()
        {
            for (int i = this.Count - 1; i > -1; i--)
            {
                Listdetail o = this[i];
                foreach (SubSonic.Where w in this.wheres)
                {
                    bool remove = false;
                    System.Reflection.PropertyInfo pi = o.GetType().GetProperty(w.ColumnName);
                    if (pi.CanRead)
                    {
                        object val = pi.GetValue(o, null);
                        switch (w.Comparison)
                        {
                            case SubSonic.Comparison.Equals:
                                if (!val.Equals(w.ParameterValue))
                                {
                                    remove = true;
                                }
                                break;
                        }
                    }
                    if (remove)
                    {
                        this.Remove(o);
                        break;
                    }
                }
            }
            return this;
        }
		
		
	}
	/// <summary>
	/// This is an ActiveRecord class which wraps the listdetail table.
	/// </summary>
	[Serializable]
	public partial class Listdetail : ActiveRecord<Listdetail>, IActiveRecord
	{
		#region .ctors and Default Settings
		
		public Listdetail()
		{
		  SetSQLProps();
		  InitSetDefaults();
		  MarkNew();
		}
		
		private void InitSetDefaults() { SetDefaults(); }
		
		public Listdetail(bool useDatabaseDefaults)
		{
			SetSQLProps();
			if(useDatabaseDefaults)
				ForceDefaults();
			MarkNew();
		}
        
		public Listdetail(object keyID)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByKey(keyID);
		}
		 
		public Listdetail(string columnName, object columnValue)
		{
			SetSQLProps();
			InitSetDefaults();
			LoadByParam(columnName,columnValue);
		}
		
		protected static void SetSQLProps() { GetTableSchema(); }
		
		#endregion
		
		#region Schema and Query Accessor	
		public static Query CreateQuery() { return new Query(Schema); }
		public static TableSchema.Table Schema
		{
			get
			{
				if (BaseSchema == null)
					SetSQLProps();
				return BaseSchema;
			}
		}
		
		private static void GetTableSchema() 
		{
			if(!IsSchemaInitialized)
			{
				//Schema declaration
				TableSchema.Table schema = new TableSchema.Table("listdetail", TableType.Table, DataService.GetInstance("sqlite"));
				schema.Columns = new TableSchema.TableColumnCollection();
				schema.SchemaName = @"main";
				//columns
				
				TableSchema.TableColumn colvarId = new TableSchema.TableColumn(schema);
				colvarId.ColumnName = "id";
				colvarId.DataType = DbType.Int64;
				colvarId.MaxLength = 8;
				colvarId.AutoIncrement = true;
				colvarId.IsNullable = false;
				colvarId.IsPrimaryKey = true;
				colvarId.IsForeignKey = false;
				colvarId.IsReadOnly = false;
				colvarId.DefaultSetting = @"";
				colvarId.ForeignKeyTableName = "";
				schema.Columns.Add(colvarId);
				
				TableSchema.TableColumn colvarListid = new TableSchema.TableColumn(schema);
				colvarListid.ColumnName = "listid";
				colvarListid.DataType = DbType.Int64;
				colvarListid.MaxLength = 8;
				colvarListid.AutoIncrement = false;
				colvarListid.IsNullable = false;
				colvarListid.IsPrimaryKey = false;
				colvarListid.IsForeignKey = false;
				colvarListid.IsReadOnly = false;
				colvarListid.DefaultSetting = @"";
				colvarListid.ForeignKeyTableName = "";
				schema.Columns.Add(colvarListid);
				
				TableSchema.TableColumn colvarFileid = new TableSchema.TableColumn(schema);
				colvarFileid.ColumnName = "fileid";
				colvarFileid.DataType = DbType.Int64;
				colvarFileid.MaxLength = 8;
				colvarFileid.AutoIncrement = false;
				colvarFileid.IsNullable = false;
				colvarFileid.IsPrimaryKey = false;
				colvarFileid.IsForeignKey = false;
				colvarFileid.IsReadOnly = false;
				colvarFileid.DefaultSetting = @"";
				colvarFileid.ForeignKeyTableName = "";
				schema.Columns.Add(colvarFileid);
				
				TableSchema.TableColumn colvarIslocal = new TableSchema.TableColumn(schema);
				colvarIslocal.ColumnName = "islocal";
				colvarIslocal.DataType = DbType.Int64;
				colvarIslocal.MaxLength = 8;
				colvarIslocal.AutoIncrement = false;
				colvarIslocal.IsNullable = false;
				colvarIslocal.IsPrimaryKey = false;
				colvarIslocal.IsForeignKey = false;
				colvarIslocal.IsReadOnly = false;
				colvarIslocal.DefaultSetting = @"";
				colvarIslocal.ForeignKeyTableName = "";
				schema.Columns.Add(colvarIslocal);
				
				TableSchema.TableColumn colvarHostid = new TableSchema.TableColumn(schema);
				colvarHostid.ColumnName = "hostid";
				colvarHostid.DataType = DbType.String;
				colvarHostid.MaxLength = 2147483647;
				colvarHostid.AutoIncrement = false;
				colvarHostid.IsNullable = true;
				colvarHostid.IsPrimaryKey = false;
				colvarHostid.IsForeignKey = false;
				colvarHostid.IsReadOnly = false;
				colvarHostid.DefaultSetting = @"";
				colvarHostid.ForeignKeyTableName = "";
				schema.Columns.Add(colvarHostid);
				
				TableSchema.TableColumn colvarHostfileid = new TableSchema.TableColumn(schema);
				colvarHostfileid.ColumnName = "hostfileid";
				colvarHostfileid.DataType = DbType.Int64;
				colvarHostfileid.MaxLength = 8;
				colvarHostfileid.AutoIncrement = false;
				colvarHostfileid.IsNullable = true;
				colvarHostfileid.IsPrimaryKey = false;
				colvarHostfileid.IsForeignKey = false;
				colvarHostfileid.IsReadOnly = false;
				colvarHostfileid.DefaultSetting = @"";
				colvarHostfileid.ForeignKeyTableName = "";
				schema.Columns.Add(colvarHostfileid);
				
				BaseSchema = schema;
				//add this schema to the provider
				//so we can query it later
				DataService.Providers["sqlite"].AddSchema("listdetail",schema);
			}
		}
		#endregion
		
		#region Props
		  
		[XmlAttribute("Id")]
		[Bindable(true)]
		public long Id 
		{
			get { return GetColumnValue<long>(Columns.Id); }
			set { SetColumnValue(Columns.Id, value); }
		}
		  
		[XmlAttribute("Listid")]
		[Bindable(true)]
		public long Listid 
		{
			get { return GetColumnValue<long>(Columns.Listid); }
			set { SetColumnValue(Columns.Listid, value); }
		}
		  
		[XmlAttribute("Fileid")]
		[Bindable(true)]
		public long Fileid 
		{
			get { return GetColumnValue<long>(Columns.Fileid); }
			set { SetColumnValue(Columns.Fileid, value); }
		}
		  
		[XmlAttribute("Islocal")]
		[Bindable(true)]
		public long Islocal 
		{
			get { return GetColumnValue<long>(Columns.Islocal); }
			set { SetColumnValue(Columns.Islocal, value); }
		}
		  
		[XmlAttribute("Hostid")]
		[Bindable(true)]
		public string Hostid 
		{
			get { return GetColumnValue<string>(Columns.Hostid); }
			set { SetColumnValue(Columns.Hostid, value); }
		}
		  
		[XmlAttribute("Hostfileid")]
		[Bindable(true)]
		public long? Hostfileid 
		{
			get { return GetColumnValue<long?>(Columns.Hostfileid); }
			set { SetColumnValue(Columns.Hostfileid, value); }
		}
		
		#endregion
		
		
			
		
		//no foreign key tables defined (0)
		
		
		
		//no ManyToMany tables defined (0)
		
        
        
		#region ObjectDataSource support
		
		
		/// <summary>
		/// Inserts a record, can be used with the Object Data Source
		/// </summary>
		public static void Insert(long varListid,long varFileid,long varIslocal,string varHostid,long? varHostfileid)
		{
			Listdetail item = new Listdetail();
			
			item.Listid = varListid;
			
			item.Fileid = varFileid;
			
			item.Islocal = varIslocal;
			
			item.Hostid = varHostid;
			
			item.Hostfileid = varHostfileid;
			
		
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}
		
		/// <summary>
		/// Updates a record, can be used with the Object Data Source
		/// </summary>
		public static void Update(long varId,long varListid,long varFileid,long varIslocal,string varHostid,long? varHostfileid)
		{
			Listdetail item = new Listdetail();
			
				item.Id = varId;
			
				item.Listid = varListid;
			
				item.Fileid = varFileid;
			
				item.Islocal = varIslocal;
			
				item.Hostid = varHostid;
			
				item.Hostfileid = varHostfileid;
			
			item.IsNew = false;
			if (System.Web.HttpContext.Current != null)
				item.Save(System.Web.HttpContext.Current.User.Identity.Name);
			else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name);
		}
		#endregion
        
        
        
        #region Typed Columns
        
        
        public static TableSchema.TableColumn IdColumn
        {
            get { return Schema.Columns[0]; }
        }
        
        
        
        public static TableSchema.TableColumn ListidColumn
        {
            get { return Schema.Columns[1]; }
        }
        
        
        
        public static TableSchema.TableColumn FileidColumn
        {
            get { return Schema.Columns[2]; }
        }
        
        
        
        public static TableSchema.TableColumn IslocalColumn
        {
            get { return Schema.Columns[3]; }
        }
        
        
        
        public static TableSchema.TableColumn HostidColumn
        {
            get { return Schema.Columns[4]; }
        }
        
        
        
        public static TableSchema.TableColumn HostfileidColumn
        {
            get { return Schema.Columns[5]; }
        }
        
        
        
        #endregion
		#region Columns Struct
		public struct Columns
		{
			 public static string Id = @"id";
			 public static string Listid = @"listid";
			 public static string Fileid = @"fileid";
			 public static string Islocal = @"islocal";
			 public static string Hostid = @"hostid";
			 public static string Hostfileid = @"hostfileid";
						
		}
		#endregion
		
		#region Update PK Collections
		
        #endregion
    
        #region Deep Save
		
        #endregion
	}
}
